package com.bbf.mathgen;

import com.bbf.mathgen.service.MathService;
import org.springframework.boot.Banner;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

import static java.lang.System.exit;

/**
 * SpringBoot 入口类
 * @author BBF
 */

@SpringBootApplication
public class Application implements CommandLineRunner {

  public static void main(String[] args) {
    SpringApplication app = new SpringApplication(Application.class);
    app.setBannerMode(Banner.Mode.OFF);
    app.run(args);
  }

  @Override
  public void run(String... args) throws Exception {
    long start = System.currentTimeMillis();
    System.out.println("\n======\n正在执行算术生成器...");
    MathService mathService = new MathService();
    // 设置20道口算题，10道比较大小题
    String fileName = mathService.createMathFile(20, 10, "d:/multiPageFormula.doc", "姓名：", 30);
    System.out.printf("执行完毕，耗时：%d 毫秒，文件路径：%s \n======\n\n", (System.currentTimeMillis() - start), fileName);
    exit(0);
  }
}
